<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>修改商品信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/themes/icon.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/demo.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/admin/css/input1.css"/>

<script src="${pageContext.request.contextPath }/plugins/jQuery/jquery.min.js"></script>
<script src="${pageContext.request.contextPath }/plugins/jQuery/jquery.easyui.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/jQuery/easyui-lang-zh_CN.js"></script>

<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/ueditor/ueditor.all.min.js"> </script>


<script>
	$(function(){

		// 区域负责人下拉列表
		$('#goods_kind').combobox({
			valueField:'dict_code',
			textField:'dict_name',
			url:'${pageContext.request.contextPath}/goods/goodskind/GOODS_KIND'
		});
		$('#goods_kind').combobox("setValue",'${goodsInfo.goods_kind}');
		
		$('#goods_packing').combobox({
			valueField:'dict_code',
			textField:'dict_name',
			url:'${pageContext.request.contextPath}/goods/goodskind/GOODS_PACKING'
		});
		$('#goods_packing').combobox("setValue",'${goodsInfo.goods_packing}');
		
		$("a[name='qsave']").linkbutton({text:'编辑商品信息',plain:true,iconCls:'icon-ok'});
		$("a[name='upload']").linkbutton({text:'重新上传',plain:true,iconCls:'icon-my-add'});
		$("a[name='find']").linkbutton({text:'点击查看',plain:true,iconCls:'icon-my-find'});
		$('#dlg').dialog('close');
		
	});
	
	function doSub(){
	
		var goods_name=$('#goods_name').val();
		if($.trim(goods_name)==''){
			$.messager.alert('系统消息','商品名称必须输入！');
			$('#sname').textbox('textbox').focus(); 
    		return;
		}
		
		var app_name=$('#app_name').val();
		if($.trim(app_name)==''){
			$.messager.alert('系统消息','APP展示名必须输入！');
			$('#app_name').textbox('textbox').focus(); 
    		return;
		}
		
		var goods_kind=$('#goods_kind').combobox('getValue');
		if($.trim(goods_kind)==''){
			$.messager.alert('系统消息','品种类型必须输入！');
			$('#goods_kind').combobox('combobox').focus(); 
    		return;
		}
		
		var goods_spec=$('#goods_spec').val();
		if($.trim(goods_spec)==''){
			$.messager.alert('系统消息','商品规格必须输入！');
			$('#goods_spec').textbox('textbox').focus(); 
    		return;
		}
		
		var goods_place=$('#goods_place').val();
		if($.trim(goods_place)==''){
			$.messager.alert('系统消息','商品产地必须输入！');
			$('#goods_place').textbox('textbox').focus(); 
    		return;
		}
		
		var goods_packing= $('#goods_packing').combobox('getValue');
		if($.trim(goods_packing)==''){
			$.messager.alert('系统消息','商品包装必须输入！');
			$('#goods_packing').combobox('combobox').focus(); 
    		return;
		}
		
		$('#addgoods').submit();
	}
	
	function showImg(imgUrl){
		$('#dlg').dialog('open');
		var image=document.getElementById("stationImg");
		image.setAttribute("src",imgUrl );
	}
	
	function uploadImg(){
		$('#upload').hide();
		$('#uploadFile').show();
	}
	
</script>
</head>

<body>
<form method="post" id="addgoods" action="${pageContext.request.contextPath }/goods/editGoodsinfo" enctype="multipart/form-data">
<div class="i-container">
	<div class="i-common i-title">编辑商品信息
		<span style="color:red; margin-left:30px;">${addMsg }</span>
		<div class="i-btn"><a id="btn" href="javascript:doSub()" name="qsave"></a></div><div style=" clear:both;"></div>
	</div>
	
    <div class="i-common i-cnt-left">商品名称：</div><div class="i-common i-cnt-right">
        <input type="hidden" name="goodsinfo.goods_id" value="${goodsInfo.goods_id }"/>
    	<input name="goodsinfo.goods_name" id="goods_name" class="easyui-textbox" value="${goodsInfo.goods_name }" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">APP展示名：</div>
    <div class="i-common i-cnt-right">
    	<input name="goodsinfo.app_name" id="app_name" class="easyui-textbox" value="${goodsInfo.app_name }" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">商品图片：</div>
    <div class="i-common i-cnt-right">
    	<div id="cancelUpload">
    		<input type="hidden" name="goodsinfo.img_url" value="${goodsInfo.img_url}"/>
    		<input type="hidden" name="goodsinfo.big_img_url" value="${goodsInfo.big_img_url }"/>
    		<span style="120px;">
    			<c:choose>
    				<c:when test="${goodsInfo.img_url eq null }">
    					<div id="uploadFile"><input class="easyui-filebox" name="img" data-options="prompt:'请选择商品图片...'" style="width:210px" accept="image/gif,image/jpeg,image/png"/></div>
    				</c:when>
    				<c:when test="${goodsInfo.img_url ne null }">
    					<div id="uploadFile" style="display:none;"><input class="easyui-filebox" name="img" data-options="prompt:'请选择商品图片...'" style="width:210px" accept="image/gif,image/jpeg,image/png"/></div>
    					<div id="upload">
	    					<span style="width:130px; font-size:12px;color:red;">已上传</span>	    					
	    					<a id="btn" href="javascript:showImg('${goodsInfo.img_url}')" name="find"></a>
	    					<a id="btn" href="javascript:uploadImg()" name="upload"></a>
    					</div>
    				</c:when>
    			</c:choose>
    		</span>
    	</div>
    	
    </div>
    <div style="clear:both;"></div>
    
    <div class="i-common i-cnt-left">品种类型：</div>
    <div class="i-common i-cnt-right">
    	<input name="goodsinfo.goods_kind" id="goods_kind" class="easyui-combobox" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">商品规格(斤)：</div>
    <div class="i-common i-cnt-right">	
    	<input name="goodsinfo.goods_spec" id="goods_spec" class="easyui-textbox" value="${goodsInfo.goods_spec }"  style="width:210px;height:26px"/>
    </div>
    
    <div style="clear:both;"></div> 
    
    <div class="i-common i-cnt-left">商品包装：</div>
    <div class="i-common i-cnt-right">
    	<input name="goodsinfo.goods_packing" id="goods_packing" class="easyui-combobox" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">优惠描述：</div>
    <div class="i-common i-cnt-right">	
    	<input name="goodsinfo.discount_desc" id="discount_desc" class="easyui-textbox" value="${goodsInfo.discount_desc }" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">商品产地：</div>
    <div class="i-common i-cnt-right">
    	<input name="goodsinfo.goods_place" id="goods_place" class="easyui-textbox" value="${goodsInfo.goods_place }" style="width:210px;height:26px"/>
    	<input type="hidden" name="goodsinfo.goods_status" value="${goodsInfo.goods_status}"/>
    	<input type="hidden" name="goodsinfo.market_type" value="${goodsInfo.market_type}"/>
    	<input type="hidden" name="goodsinfo.put_time" value='<fmt:formatDate value="${goodsInfo.put_time}" pattern="yyyy-MM-dd HH:mm:ss"/>'/>
    	<input type="hidden" name="goodsinfo.off_time" value='<fmt:formatDate value="${goodsInfo.off_time}" pattern="yyyy-MM-dd HH:mm:ss"/>'/>
    	<input type="hidden" name="goodsinfo.create_time" value='<fmt:formatDate value="${goodsInfo.create_time}" pattern="yyyy-MM-dd HH:mm:ss"/>'/>
    	<input type="hidden" name="goodsinfo.status" value="${goodsInfo.status}"/>
    </div>
    <div style="clear:both;"></div> 
 	
    <div class="i-common i-cnt-left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;商品明细：</div>
    <div class="i-common i-cnt-left" style="width:99%; text-align:left; background-color:white; height:auto;">	
    	<textarea id="editor" style="width:100%;" id="goods_detail" name="goodsinfo.goods_detail">${goodsInfo.goods_detail} </textarea>
    	<script type="text/javascript"> 
    		UE.getEditor("editor");
    	</script>
    </div>
    <div style="clear:both;"></div>
    
    <div id="dlg" class="easyui-dialog" title="商品图片查看" style="width:190px;height:220px;max-width:800px;padding:10px" data-options="
		onResize:function(){
			$(this).dialog('center');
		}">
		<img id="stationImg" src="" style="width:150px;height:150px;"/>
    </div>
    
</div>

</form>
</body>
</html>

